/**
 * @ author: 汪孟苹
 */
define(['jquery',"bbcare",
	"scprit/followup/app/patientManager/addPatient.servers.js",
	"scprit/followup/app/patientManager/addPatient.ui.js",
	"scprit/followup/app/patientManager/addPatient.event.js"
	],
	function($,$bb,$addPatientServers,$addPatientUi,$addPatientEvent){
	var addPatient = {};
	/**
	 * 请求队列成功后的回调函数
	 */
	var getQueuesCallback = function(data){
		$addPatientUi.queues({	// 队列列表
			id: "queueList",
			list: data.rows,
		});
		var pageParams = $bb.getPageParams();
		var topbars = [
			{
				"icon":"fa fa-times",
				"name":"关闭",
				"params":pageParams,
				"callback":$addPatientEvent.onCloseSelect
			}
		];
        $bb.toolbar(topbars);
		var params = $addPatientServers.getInitQueueParams(data);
		/* 点击哪个队列就渲染哪个队列的详细建档问卷 */
		$("#queueList .queue-card").unbind("click");
		$("#queueList .queue-card").click($addPatientEvent.onQueueNavSelect);
		if( pageParams && pageParams.followQueueId ){
			var index = $addPatientServers.getCurQueue(data.rows,pageParams.followQueueId);
			$("#queueList .queue-card").eq(index).click();
			$("#queueList").css({"display":"none"});
		}else{
			$("#queueList .queue-card:first-child").click();
		}
	}
	/**
	 * 建档页面初始化
	 */
	addPatient.init = function(){
		$addPatientServers.ajaxQueueList(getQueuesCallback);
	};

	return addPatient;
});